-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SCHEDULE] New Reduction Mode for Tensorize #727
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are some codestyle problem, you can reproduce locally via make lint. Other comments are explicitly inlined
src/op/op_util.cc
Outdated
Stmt body, | ||
Stmt update) | ||
{ | ||
Expr condition = (make_zero(Int(32)) == make_zero(Int(32))); //will try Bool(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build a Array<Expr>
containing condition, use https://github.com/dmlc/tvm/blob/master/src/arithmetic/compute_expr.h#L42 to do reduction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, please check
src/op/op_util.cc
Outdated
auto vit = dom_map.find(iv); | ||
CHECK(vit != dom_map.end()); | ||
const Range& vrange = vit->second; | ||
Expr newcond = ( iv->var == vrange->min); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use condition
if (likely(var1> min1) or likely(var2 > min2)) {
update
} else {
body
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/op/op_util.cc
Outdated
@@ -208,5 +208,31 @@ Stmt Substitute(Stmt s, | |||
return ir::Substitute(s, init); | |||
} | |||
|
|||
Stmt TransformUpdate(const Stage& stage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is specific to Tensorize, move it to tensorize.cc, no need to keep comment in header file, move comment document to tensorize.cc as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, move the function into tensorize.cc
src/op/tensorize.cc
Outdated
update = MergeNest(update_nest, update); | ||
return MergeNest(common, Block::make(init, update)); | ||
} else { | ||
// The update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment about what this logic is about. Something like
// when init intrinsic is not available, transform to reset in the first iter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/op/tensorize.cc
Outdated
return MergeNest(common, Block::make(init, update)); | ||
} else { | ||
// The update | ||
Stmt update = TransformUpdate (stage, dom_map, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add CHECK(body.defined());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Please add a unittestcase to https://github.com/dmlc/tvm/blob/master/tests/python/unittest/test_schedule_tensorize.py#L1 |
there is one additional drawback of the approach which requires additional verification. We cannot let the For example, if condition contains rc>1 (and rc is from [0, n) ), then the initial checking condition is no longer correct. Error shall be raised when such case is detected. This can be done via something similar to https://github.com/dmlc/tvm/blob/master/src/op/tensorize.cc#L124 |
src/op/tensorize.cc
Outdated
CHECK(intrin->reduce_init.defined()) | ||
<< "Reduction init op for intrin " << intrin << " is not defined"; | ||
// Comment out the following check for the case when there is no init func | ||
//CHECK(intrin->reduce_init.defined()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove lgtm, simply remove them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Refined the code per review comment, and add a test case in unittest, will add more cases in the following days. |
@@ -0,0 +1,90 @@ | |||
import tvm | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to test_schedule_tensorize.py We can use different function name
* when there is no intrin func, using body for initialization. For issue 714. * Refine code per review comments, and add a test case. * Fix lint issues.
* when there is no intrin func, using body for initialization. For issue 714. * Refine code per review comments, and add a test case. * Fix lint issues.
* when there is no intrin func, using body for initialization. For issue 714. * Refine code per review comments, and add a test case. * Fix lint issues.
…e 714. @tqchen , This fix can resolve the original issue which I raised. Please review it , thanks.